package com.gxar.marketdelivery.domain.validator;

import com.fasterxml.jackson.databind.node.ObjectNode;
import com.gxar.marketdelivery.shared.model.DeliveryMaterialModel;
import com.gxar.marketdelivery.shared.utils.JsonSchemaUtil;
import com.gxar.marketdelivery.shared.utils.StringUtils;

/**
 * @author nice
 * @version 1.0
 * @created 2023/7/21.
 */
public class SchemaValidator {

    public static void validateMaterial(String schemaDefinition, DeliveryMaterialModel material) {
        if (material == null) {
            return;
        }
        //校验静态物料值
        ObjectNode staticJsonNode = null;
        if (StringUtils.isNotBlank(material.getStaticSchemaValue())) {
            staticJsonNode = JsonSchemaUtil.parseJson(material.getStaticSchemaValue());
            JsonSchemaUtil.validate(schemaDefinition, staticJsonNode);
        }
    }
}
